<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>
    <transition>
      <h1 class="bg" v-show="isShow">你好啊！</h1>
    </transition>

    <!-- <transition name="hello" :appear="true">
      <h1 class="bg" v-show="isShow">你好啊！</h1>
    </transition> -->

    <!-- appear作用是初始化有动效 -->
    <transition name="hello" appear >
      <h1 class="bg" v-show="isShow">你好啊！</h1>
    </transition>
  </div>
</template>

<script>
  export default {
    name: 'Test',
    data() {
      return {
        isShow: true
      }
    }
  };
</script>

<style scoped>
  .bg {
    background-color: chocolate;
  }

  /* .come {
    animation: atguigu 1s;
  }

  .go {
    animation: atguigu 1s reverse;
  } */

  @keyframes atguigu {
    from {
      transform: translateX(-100%);
    }
    to {
      transform: translateX(0);
    }
  }

  /* 进入时激活 */
  .v-enter-active {
    animation: atguigu 0.5s linear;
  }

  /* 离开时激活 */
  .v-leave-active {
    animation: atguigu 0.5s linear reverse;
  }

  /* 进入时激活 */
  .hello-enter-active {
    animation: atguigu 0.5s linear;
  }

  /* 离开时激活 */
  .hello-leave-active {
    animation: atguigu 0.5s linear reverse;
  }
</style>